const http = require('http')
const routes = require('./module/routes')
const url = require('url')

http.createServer((req, res) => {
  routes['static'](req, res, 'static')
  const pathname = url.parse(req.url).pathname.replace('/','')
  try {
    routes[pathname](req, res);
  } catch (err) {
    // routes['error'](req, res); // 写了就报错
  }
}).listen(8081)
